package com.moody.hibernate.dao;

import java.util.ArrayList;
import java.util.List;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.moody.hibernate.domain.EnterBalanceSheet;
import com.moody.hibernate.domain.EnterCashFlow;
import com.moody.hibernate.domain.EnterIncome;
import com.moody.hibernate.domain.FinanFinancialIndexSheet;
import com.moody.hibernate.domain.PublicBalanceSheet;
import com.moody.hibernate.domain.PublicIncomeSheet;
import com.moody.hibernate.domain.FinanBalanceSheet;
import com.moody.hibernate.domain.FinanIncomeSheet;
import com.moody.hibernate.domain.ReportData;
import com.moody.hibernate.domain.ReportDataId;
import com.moody.hibernate.domain.ReportList;
import com.moody.hibernate.domain.SmallBalanceSheet;
import com.moody.hibernate.domain.SmallCashFlowSheet;
import com.moody.hibernate.domain.SmallIncomeSheet;


/**
 	* A data access object (DAO) providing persistence and search support for ReportData entities.
 			* Transaction control of the save(), update() and delete() operations 
		can directly support Spring container-managed transactions or they can be augmented	to handle user-managed Spring transactions. 
		Each of these methods provides additional information for how to configure it for the desired type of transaction control. 	
	 * @see com.moody.hibernate.domain.ReportData
  * @author MyEclipse Persistence Tools 
 */

public class ReportDataDAO extends HibernateDaoSupport  {
	     private static final Logger log = LoggerFactory.getLogger(ReportDataDAO.class);
		//property constants
	public static final String DISPLAY_NAME = "displayName";
	public static final String REPORT_ITEM_NO = "reportItemNo";
	public static final String ITEM_VALUE = "itemValue";



	protected void initDao() {
		//do nothing
	}
    
    public void save(ReportData transientInstance) {
        log.debug("saving ReportData instance");
        try {
            getHibernateTemplate().save(transientInstance);
            log.debug("save successful");
        } catch (RuntimeException re) {
            log.error("save failed", re);
            throw re;
        }
    }
    
	public void delete(ReportData persistentInstance) {
        log.debug("deleting ReportData instance");
        try {
            getHibernateTemplate().delete(persistentInstance);
            log.debug("delete successful");
        } catch (RuntimeException re) {
            log.error("delete failed", re);
            throw re;
        }
    }
    
    public ReportData findById( com.moody.hibernate.domain.ReportDataId id) {
        log.debug("getting ReportData instance with id: " + id);
        try {
            ReportData instance = (ReportData) getHibernateTemplate()
                    .get("com.moody.hibernate.domain.ReportData", id);
            return instance;
        } catch (RuntimeException re) {
            log.error("get failed", re);
            throw re;
        }
    }
    
    
    public List findByExample(ReportData instance) {
        log.debug("finding ReportData instance by example");
        try {
            List results = getHibernateTemplate().findByExample(instance);
            log.debug("find by example successful, result size: " + results.size());
            return results;
        } catch (RuntimeException re) {
            log.error("find by example failed", re);
            throw re;
        }
    }    
    
    public List findByProperty(String propertyName, Object value) {
      log.debug("finding ReportData instance with property: " + propertyName
            + ", value: " + value);
      try {
         String queryString = "from ReportData as model where model." 
         						+ propertyName + "= ?";
		 return getHibernateTemplate().find(queryString, value);
      } catch (RuntimeException re) {
         log.error("find by property name failed", re);
         throw re;
      }
	}

	public List findByDisplayName(Object displayName
	) {
		return findByProperty(DISPLAY_NAME, displayName
		);
	}
	
	public List findByReportItemNo(Object reportItemNo
	) {
		return findByProperty(REPORT_ITEM_NO, reportItemNo
		);
	}
	
	public List findByItemValue(Object itemValue
	) {
		return findByProperty(ITEM_VALUE, itemValue
		);
	}
	

	public List findAll() {
		log.debug("finding all ReportData instances");
		try {
			String queryString = "from ReportData";
		 	return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}
	
    public ReportData merge(ReportData detachedInstance) {
        log.debug("merging ReportData instance");
        try {
            ReportData result = (ReportData) getHibernateTemplate()
                    .merge(detachedInstance);
            log.debug("merge successful");
            return result;
        } catch (RuntimeException re) {
            log.error("merge failed", re);
            throw re;
        }
    }

    public void attachDirty(ReportData instance) {
        log.debug("attaching dirty ReportData instance");
        try {
            getHibernateTemplate().saveOrUpdate(instance);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }
    
    public void attachClean(ReportData instance) {
        log.debug("attaching clean ReportData instance");
        try {
            getHibernateTemplate().lock(instance, LockMode.NONE);
            log.debug("attach successful");
        } catch (RuntimeException re) {
            log.error("attach failed", re);
            throw re;
        }
    }

	public static ReportDataDAO getFromApplicationContext(ApplicationContext ctx) {
    	return (ReportDataDAO) ctx.getBean("ReportDataDAO");
	}
	
	
	/*
	 * 以下代码非自动生成
	 */
	
	public void insertReportDataList(List<ReportData> list){
		try{
			getHibernateTemplate().saveOrUpdateAll(list);
		}catch (Exception e){
			log.error("insert error", e);
		}
	}
	
	//根据某报表查询该报表的数据项
	@SuppressWarnings("unchecked")
	public List<ReportData> findRecentReportData(ReportList recentReport, String reportNo) {
		List<ReportData> list = new ArrayList<ReportData>();
		if(reportNo.equals(""))
			reportNo = "*";
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.reportNo = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ?  and rd.id.displayNo <> ?order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,recentReport.getId().getCustId(),reportNo, 
					recentReport.getId().getAccountMonth(),recentReport.getId().getReportScope(),"0");
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}
	//根据报表简要信息查询该报表的数据项
	@SuppressWarnings("unchecked")
	public List<ReportData> findRecentReportData(ReportList recentReport) {
		List<ReportData> list = new ArrayList<ReportData>();
		
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ? and rd.id.displayNo <> ? order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,recentReport.getId().getCustId(), 
					recentReport.getId().getAccountMonth(),recentReport.getId().getReportScope(),"0");
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}

	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedEnterIncomeData(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ?  and rd.id.reportNo = ? and rd.id.displayNo <> ? " +
				"order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(), report.getId().getReportScope(),EnterIncome.REPORTNO,"0");
		}catch (Exception e){
			log.error("query error", e);
			return null;
		}
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedFinanIncomeData(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ?  and rd.id.reportNo = ? and rd.id.displayNo <> ? " +
				"order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(), report.getId().getReportScope(),FinanIncomeSheet.REPORTNO,"0");
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}
	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedFinanFinancialIndexData(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ?  and rd.id.reportNo = ? and rd.id.displayNo <> ? " +
				"order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(), report.getId().getReportScope(),FinanFinancialIndexSheet.REPORTNO,"0");
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedEnterBalanceData(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ?  and rd.id.reportNo = ? and rd.id.displayNo <> ? " +
				"order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(), report.getId().getReportScope(),EnterBalanceSheet.REPORTNO,"0");
		}catch (Exception e){
			log.error("query error", e);
			return null;
		}
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedSmallBalanceData(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ?  and rd.id.reportNo = ? and rd.id.displayNo <> ? " +
				"order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(), report.getId().getReportScope(),SmallBalanceSheet.REPORTNO,"0");
		}catch (Exception e){
			log.error("query error", e);
			return null;
		}
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedFinanBalanceData(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ?  and rd.id.reportNo = ? and rd.id.displayNo <> ? " +
				"order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(), report.getId().getReportScope(),FinanBalanceSheet.REPORTNO,"0");
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}

	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedEnterAsset(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ? and CAST(rd.id.displayNo as integer) < ? and rd.id.reportNo = ? and rd.id.displayNo <> ? order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(),report.getId().getReportScope(),EnterBalanceSheet.FLAG+1,EnterBalanceSheet.REPORTNO, "0");
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}

	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedSmallAsset(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ? and CAST(rd.id.displayNo as integer) < ? and rd.id.reportNo = ? and rd.id.displayNo <> ? order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(),report.getId().getReportScope(),SmallBalanceSheet.FLAG+1,SmallBalanceSheet.REPORTNO, "0");
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedFinanAsset(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ? and CAST(rd.id.displayNo as integer) < ? and rd.id.reportNo = ? and rd.id.displayNo <> ? order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(),report.getId().getReportScope(),FinanBalanceSheet.FLAG+1,FinanBalanceSheet.REPORTNO, "0");
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}

	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedEnterDebt(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ? and CAST(rd.id.displayNo as integer) > ? and rd.id.reportNo = ? order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(),report.getId().getReportScope(),EnterBalanceSheet.FLAG,EnterBalanceSheet.REPORTNO);
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}

	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedSmallDebt(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ? and CAST(rd.id.displayNo as integer) > ? and rd.id.reportNo = ? order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(),report.getId().getReportScope(),SmallBalanceSheet.FLAG,SmallBalanceSheet.REPORTNO);
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}
	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedFinanDebt(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ? and CAST(rd.id.displayNo as integer) > ? and rd.id.reportNo = ? order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(),report.getId().getReportScope(),FinanBalanceSheet.FLAG,FinanBalanceSheet.REPORTNO);
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}

	//报表是否是确定状态
	@SuppressWarnings("unchecked")
	public boolean isReportReady(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ? and rd.displayFlag = ? ";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(),report.getId().getReportScope(),ReportData.TEMPSAVE);
		}catch (Exception e){
			log.error("query error", e);
		}
		if(list.size()>0)
			return false;
		else
			return true;
	}

	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedEnterCashFlowData(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ?  and rd.id.reportNo = ? and rd.id.displayNo <> ? " +
				"order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(), report.getId().getReportScope(),EnterCashFlow.REPORTNO,"0");
		}catch (Exception e){
			log.error("query error", e);
			return null;
		}
		return list;
	}

	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedSmallCashFlowData(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ?  and rd.id.reportNo = ? and rd.id.displayNo <> ? " +
				"order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(), report.getId().getReportScope(),SmallCashFlowSheet.REPORTNO,"0");
		}catch (Exception e){
			log.error("query error", e);
			return null;
		}
		return list;
	}

	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedPublicBalanceData(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ?  and rd.id.reportNo = ? and rd.id.displayNo <> ? " +
				"order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(), report.getId().getReportScope(),PublicBalanceSheet.REPORTNO,"0");
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}

	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedPublicAsset(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ? and CAST(rd.id.displayNo as integer) < ? and rd.id.reportNo = ? and rd.id.displayNo <> ? order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(),report.getId().getReportScope(),PublicBalanceSheet.FLAG+1,PublicBalanceSheet.REPORTNO, "0");
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}

	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedPublicDebt(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ? and CAST(rd.id.displayNo as integer) > ? and rd.id.reportNo = ? order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(),report.getId().getReportScope(),PublicBalanceSheet.FLAG,PublicBalanceSheet.REPORTNO);
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedPublicRevenue(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ? and CAST(rd.id.displayNo as integer) < ? and rd.id.reportNo = ? and rd.id.displayNo <> ? order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(),report.getId().getReportScope(),PublicIncomeSheet.FLAG1+1,PublicIncomeSheet.REPORTNO, "0");
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}

	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedPublicExpend(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ? and CAST(rd.id.displayNo as integer) > ? " +
				"and CAST(rd.id.displayNo as integer) < ? and rd.id.reportNo = ? order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(),report.getId().getReportScope(),PublicIncomeSheet.FLAG1,PublicIncomeSheet.FLAG2+1,PublicIncomeSheet.REPORTNO);
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}

	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedPublicSurplus(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ? and CAST(rd.id.displayNo as integer) > ? and rd.id.reportNo = ? order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(),report.getId().getReportScope(),PublicIncomeSheet.FLAG2,PublicIncomeSheet.REPORTNO);
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedPublicIncome(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ?  and rd.id.reportNo = ? and rd.id.displayNo <> ? " +
				"order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(), report.getId().getReportScope(),PublicIncomeSheet.REPORTNO,"0");
		}catch (Exception e){
			log.error("query error", e);
		}
		return list;
	}

	@SuppressWarnings("unchecked")
	public List<ReportData> findSortedSmallIncome(ReportList report) {
		List<ReportData> list = new ArrayList<ReportData>();
		try{
		String hql = "from ReportData as rd where rd.id.custId = ? and rd.id.accountMonth = ?   " +
				"and rd.id.reportScope = ?  and rd.id.reportNo = ? and rd.id.displayNo <> ? " +
				"order by CAST(rd.id.displayNo as integer)";
			list = getHibernateTemplate().find(hql,report.getId().getCustId(),
					report.getId().getAccountMonth(), report.getId().getReportScope(),SmallIncomeSheet.REPORTNO,"0");
		}catch (Exception e){
			log.error("query error", e);
			return null;
		}
		return list;
	}
	
	@SuppressWarnings("unchecked")
	public List<ReportData> findInCondition(String custId, String accountMonth, String reportNo){
		String hql = "from ReportData where custId like :custId and accountMonth like :accountMonth and reportNo like :reportNo ";
		Session session = getHibernateTemplate().getSessionFactory().openSession();
		Query query = session.createQuery(hql);
		query.setString("custId", custId);
		query.setString("accountMonth",accountMonth);
		query.setString("reportNo", "%"+ reportNo);
		List<ReportData> list = query.list();
		session.close();
		return list;
		
	}
	
}